/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.univcasa.biz.impl;

import com.univcasa.biz.AccountDistributer;
import com.univcasa.biz.impl.exception.CompteNotFoundException;
import com.univcasa.biz.impl.exception.EtudiantNotFoundException;
import com.univcasa.db.model.CompteEtudiant;
import com.univcasa.db.model.ComptePersonnel;
import com.univcasa.db.model.Criteres;
import com.univcasa.managing.ComptesPersManager;
import com.univcasa.managing.ComptesStudentsManager;
import com.univcasa.managing.LdapDBManager;
import com.univcasa.managing.impl.ComptesPersManagerImpl;
import com.univcasa.managing.impl.ComptesStudentsManagerImpl;
import com.univcasa.managing.impl.LdapDBManagerImpl;

/**
 *
 * @author issam
 */
public class AccountDistributerImpl implements AccountDistributer {

    private ComptesStudentsManager comptesStdManager;
    private ComptesPersManager comptesPersManager;
    private LdapDBManager ldapManager;

    public AccountDistributerImpl() {
        comptesStdManager = new ComptesStudentsManagerImpl();
        comptesPersManager = new ComptesPersManagerImpl();
        ldapManager = new LdapDBManagerImpl();
    }



    public CompteEtudiant getAccountStdByCriteria(Criteres criteres) throws EtudiantNotFoundException {
        
        CompteEtudiant etudiant = comptesStdManager.getCompteEtudiantByCriteria( criteres );
        if (etudiant ==null){
            throw new EtudiantNotFoundException();
        }
        return etudiant;
    }

    public ComptePersonnel getAccountPersByCriteria(Criteres criteres) throws CompteNotFoundException {

        ComptePersonnel pers = comptesPersManager.getComptePersByCriteria( criteres );
        if (pers ==null){
            throw new CompteNotFoundException();
        }
        return pers;
    }

    public boolean reInitPass(CompteEtudiant std) {
        return ldapManager.majCompteEtudiantLdap(std);
    }

    public boolean reInitPass(ComptePersonnel pers) {
        return ldapManager.majComptePersLdap( pers );
    }
}
